package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.nursing.domain.Reservation;
import com.zzyl.nursing.service.IMemberVisitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author XS
 * @Date 2025/10/22 21:48
 */
@RestController
@RequestMapping("/member/reservation")
public class MemberVisitController extends BaseController {
    @Autowired
    private IMemberVisitService memberVisitService;


    /**
     * 查询当天取消预约的数量
     */
    @GetMapping("/cancelled-count")
    public AjaxResult cancelledCount() {

        int count = memberVisitService.getCount();

        return count>3?AjaxResult.error("今日取消预约数量已超过3个"):AjaxResult.success("今日取消预约数量未超过3个");
    }
    /**
     * 新增预约
     */
    @PostMapping
    public AjaxResult addReservation(@RequestBody Reservation reservation) {
        memberVisitService.saveReservation(reservation);
        return AjaxResult.success("预约成功");
    }

}
